﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.EntityFrameworkCore;
using RescueApp.Data;

namespace Rescue.UI
{
    public partial class RescueMain : Form
    {
        RescueContext _db;
        public RescueMain()
        {
            InitializeComponent();
            _db = new RescueContext(Config.ConnectingStr);
        }

        private void button1_Click(object sender, EventArgs e)//用户模式
        {
            RescueApplyDetails frmRepo = new RescueApplyDetails(_db);
            frmRepo.ShowDialog();
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                _db.Database.GetDbConnection().Open();
                MessageBox.Show("数据库连接成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"数据库连接失败:{ex.Message},退出系统！");
                Application.Exit();
            }
        }

        private void button2_Click(object sender, EventArgs e)//管理员模式
        {
            DispatchDetails frmRepo = new DispatchDetails(_db);
            frmRepo.ShowDialog();
        }
    }
}
